**************************************************************************************************
*** This do file creates the replication results for 
*** Eric Neumayer, Katharina Pfaff and Thomas Pluemper.
*** Protest against Covid-19 Containment Policies in European Countries 
*** Published in: Journal of Peace Research  
							
**************************************************************************************************
**************************************************************************************************
/* Note: You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 
/* You must have Stata version 13 or higher installed													*/
**************************************************************************************************
*/

drop _all
clear matrix
clear mata


capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o) /* checks whether outreg2 is installed 		*/



***********************************************************************************
local DIR = "D:\Research\Health for all database\Europe\"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************

** Estimation results
use  "Article for JPR (C19).dta", clear

tsset

** table 1
* base
nbreg monthly_count_C19_events  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
outreg2 using table1.xls, excel replace   

* full and partial measures separated
nbreg monthly_count_C19_events  ecdc_agg_sum1 ecdc_agg_sum1_p   monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
outreg2 using table1.xls, excel append   

** table 2
* Oxford stringency measure
nbreg monthly_count_C19_events  containmenthealthindex   monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
outreg2 using table2.xls, excel replace   
corr containmenthealthindex ecdc_agg_sum1_both if e(sample)

* Replacing mortality rate with case rate
nbreg monthly_count_C19_events  ecdc_agg_sum1_both  monthly_cases_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
outreg2 using table2.xls, excel append   

* Replacing number of protest events with size of events
nbreg size_total  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
outreg2 using table2.xls, excel append   
corr monthly_count_C19_events size_total if e(sample)


* with month fixed effects & LDV
nbreg monthly_count_C19_events l.monthly_count_C19_events ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop i.month if month>=3, cluster(country_id)
outreg2 using table2.xls, excel append   

* with country fixed effects 
quietly nbreg monthly_count_C19_events  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
xtnbreg monthly_count_C19_events  ecdc_agg_sum1_both monthly_deaths_rate_14_day if e(sample), fe vce(jackknife)
outreg2 using table2.xls, excel append   



** Appendix 1
use  "Article for JPR (C19).dta", clear

tsset

quietly nbreg monthly_count_C19_events  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
keep if e(sample)
collapse (sum) monthly_count_C19_events, by(country)
list country monthly_count_C19_events

use  "Article for JPR (C19).dta", clear

tsset

quietly nbreg monthly_count_C19_events  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
keep if e(sample)
collapse (sum) monthly_count_C19_events, by(month)
list month monthly_count_C19_events


** Appendix 2
use  "Article for JPR (C19).dta", clear

tsset

quietly nbreg monthly_count_C19_events  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3, cluster(country_id)
sum monthly_count_C19_events  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if e(sample)


** Some descriptive statistics

* total protest across countries
use  "Article for JPR (C19).dta", clear

quietly nbreg monthly_count_C19_events monthly_deaths_rate_14_day ecdc_agg_sum1_both gdp_pc trust_gov_pubadmin_2020 civilliberties ln_pop if month>=3, cluster(country_id)
keep if e(sample)
collapse (sum) monthly_count_C19_events, by(country)
gsort -monthly_count_C19_events
list


* total protest across time
use  "Article for JPR (C19).dta", clear

quietly nbreg monthly_count_C19_events monthly_deaths_rate_14_day ecdc_agg_sum1_both gdp_pc trust_gov_pubadmin_2020 civilliberties ln_pop if month>=3, cluster(country_id)
keep if e(sample)
collapse (sum) monthly_count_C19_events, by(month)
gsort -monthly_count_C19_events
list

* highest and lowest values of key variables
use  "Article for JPR (C19).dta", clear

quietly nbreg monthly_count_C19_events monthly_deaths_rate_14_day ecdc_agg_sum1_both gdp_pc trust_gov_pubadmin_2020 civilliberties ln_pop if month>=3, cluster(country_id)
keep if e(sample)
gsort -monthly_deaths_rate_14_day
list country month monthly_deaths_rate_14_day
gsort -ecdc_agg_sum1_both
list country month ecdc_agg_sum1_both


collapse ecdc_agg_sum1_both, by(country)
gsort - ecdc_agg_sum1_both
list 


** Counterfactual effect estimates

use  "Article for JPR (C19).dta", clear

nbreg monthly_count_C19_events  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3 & month<=20, cluster(country_id)
keep if e(sample)
local counter
local counter = 0
capture drop  counter`counter'_atasobs
gen  counter`counter'_atasobs=.

capture drop holder holder2 x1_holder x2_holder
predict holder

gen x1_holder=monthly_deaths_rate_14_day
gen x2_holder=ecdc_agg_sum1_both
replace monthly_deaths_rate_14_day = `counter'
replace ecdc_agg_sum1_both = `counter'
predict holder2
replace monthly_deaths_rate_14_day=x1_holder
replace ecdc_agg_sum1_both=x2_holder

qui replace counter`counter'_atasobs = (holder-holder2)


keep country month monthly_count_C19_events monthly_deaths_rate_14_day ecdc_agg_sum1_both counter0_atasobs

save "counterfactual effect death rate & stringency zero", replace


use  "Article for JPR (C19).dta", clear

nbreg monthly_count_C19_events  ecdc_agg_sum1_both  monthly_deaths_rate_14_day civilliberties trust_gov_pubadmin_2020  gdp_pc ln_pop if month>=3 & month<=20, cluster(country_id)
keep if e(sample)
local counter
local counter = 0
capture drop  counter`counter'_atasobs
gen  counter`counter'_atasobs=.

capture drop holder holder2 x1_holder x2_holder
predict holder

gen x1_holder=civilliberties
gen x2_holder=trust_gov_pubadmin_2020
replace civilliberties = `counter'
replace trust_gov_pubadmin_2020 = `counter'
predict holder2
replace civilliberties=x1_holder
replace trust_gov_pubadmin_2020=x2_holder

qui replace counter`counter'_atasobs = (holder-holder2)


keep country month monthly_count_C19_events civilliberties trust_gov_pubadmin_2020 counter0_atasobs

save "counterfactual effect civilliberties & trust zero", replace